/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * <p>Project: jse2302 - ForDemo
 * <p>Powered by webrx On 2023-06-27 16:48:24
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class ForDemo {

    public static void main(String[] args) {


        for (int i = 0; i < 5; i++) {
            System.out.println(i);
        }
        System.out.println("for(;;)--------------------------");
        String[] ss = new String[]{"aa", "bb", "cc", "dd"};
        for (int i = 0; i < ss.length; i++) {
            System.out.println(ss[i]);
        }
        System.out.println("for :--------------------------");
        for (String s : ss) {
            System.out.println(s);
        }

        //String[] 转 List<String>
        List<String> lists = Arrays.asList(ss);
        System.out.println(lists);
        Collections.reverse(lists);
        for (String s : lists) {
            System.out.println(s);
        }

        //List<String> 转 String[]
        Object[] array = lists.toArray();
        System.out.println(Arrays.toString(array));
        System.out.println("------");
        String[] ss2 = new String[lists.size()];
        lists.toArray(ss2);
        System.out.println(Arrays.toString(ss2));


        //List<Integer> list = new ArrayList<>(List.of(10, 5, 6, 20, 15, 30));
        //Collections.reverse(list);
        //for(int i : list){
        //    System.out.println(i);
        //}

    }
}
